<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script>
    function swipeUp (ele, handler) {
      var 
        x = 0,
        y = 0
      ele.addEventListener('touchstart', function (e) {
        x = e.changedTouches[0].clientX
        y = e.changedTouches[0].clientY
      })

      ele.addEventListener('touchend', function (e) {
        var 
          moveY = y - e.changedTouches[0].clientY,
          moveX = Math.abs(x - e.changedTouches[0].clientX)
        if (moveY > moveX) {
          handler.call(this, e)          
        }
      })
    } 
    
    function swipeRight (ele, handler) {
      var 
        x = 0,
        y = 0
      ele.addEventListener('touchstart', function (e) {
        x = e.changedTouches[0].clientX
        y = e.changedTouches[0].clientY
      })

      /* ele.addEventlistener('touchmove', function (e) {
        var moveX = 
      }) */

      ele.addEventListener('touchend', function (e) {
        var 
          moveY = Math.abs(y - e.changedTouches[0].clientY),
          moveX = e.changedTouches[0].clientX - x
        if (moveY < moveX) {
          handler.call(this, e)
        }
      })
    } 

    swipeUp(document, function () {
      console.log('上滑动')
    })

    swipeRight(document, function () {
      console.log('右滑动')
    })
    
  </script>
</body>
</html>